<include file="/public/header" />
<!-- // 重定位Style -->
<style>
    .layui-card-header.layuiadmin-card-header-auto {
        border-bottom: 0px;
        padding-bottom: 0px;
    }

    .layui-card-body {
        padding: 0px 30px;
        padding-bottom: 5px;
    }

    .layui-card-header h5 {
        font-size: 16px;
    }

    .layui-table-tool-temp {
        padding-right: 0px;
    }

</style>
<div class="layui-col-md4">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-header layuiadmin-card-header-auto" style="padding-bottom: 5px">
                <div class="layui-inline layui-hide" id="toolbar">
                    <!-- // 添加数据页面 -->
                    <button class="layui-btn icon-btn" lay-batch="lay-tree"  lay-url="{:url('/system.database/optimize')}" lay-nodel="false" >
                        <i class="layui-icon layui-icon-add-1"></i>{:__('优化')}
                    </button>
                    <button class="layui-btn icon-btn" lay-batch="lay-tree"  lay-url="{:url('/system.database/repair')}" lay-nodel="false" >
                        <i class="layui-icon layui-icon-senior"></i>{:__('修复')}
                    </button>
                    <button class="layui-btn icon-btn" lay-batch="lay-tree"  lay-url="{:url('/system.database/export')}" lay-nodel="false" >
                        <i class="layui-icon layui-icon-export"></i>{:__('备份')}
                    </button>
                    <button class="layui-btn icon-btn" lay-open="" lay-title="{:__('数据库配置')}" lay-area="500px,340px" lay-url="{:url('/system.database/config')}" >
                        <i class="layui-icon layui-icon-form"></i>{:__('数据库配置')}
                    </button>
                </div>
            </div>
            <div class="layui-card-body">
                <!-- // 创建数据实例 -->
                <table class="layui-table" 
                    lay-data="{
                    url:'{:url('/system.database/index/')}?table=admin', 
                    toolbar: '#toolbar',
                    defaultToolbar: [],
                    id:'lay-tree'}" 
                    lay-filter="lay-tree">
                  <thead>
                    <tr>
                      <th lay-data="{type:'checkbox'}"></th>
                      <th lay-data="{field:'name'}">{:__('数据表')}</th>
                      <th lay-data="{field:'comment'}">{:__('数据表说明')}</th>
                      <th lay-data="{field:'data_length'}">{:__('数据大小')}</th>
                    </tr>
                  </thead>
                </table>
            </div>
        </div>
    </div>
</div>

<div class="layui-col-md8" >
    <!-- // 展示数据 -->
    <div class="layui-fluid">
        <div class="layui-card">
            <!-- // 创建数据实例 -->
            <table id="lay-tableList" lay-filter="lay-tableList"></table>        
        </div>
    </div>
</div>

<include file="/public/footer" />
<script>
    layui.use(['jquery','table'], function () {

        var jquery = layui.jquery;
        var table = layui.table; 

        // 定义表格URL
        var tableURL = "{:url('/system.database/index')}";
        // 基础表格
        var isTable = table.render({
            elem: "#lay-tableList"
            ,url: tableURL
            ,cols: [[
                {type: 'numbers', title: '{:__("ID")}'},
                {field: 'field', align: 'center', title: '{:__("字段")}'},
                {field: 'comment', align: 'center', title: '{:__("字段注释")}'},
                {field: 'type', align: 'center', title: '{:__("数据类型")}'},
                {field: 'default', align: 'center', title: '{:__("默认值")}'},
                {field: 'null', align: 'center', title: '{:__("非空值")}'},
                {field: 'collation', align: 'center', title: '{:__("排序规则")}'},
            ]]
        })

        table.on('checkbox(lay-tree)', function(obj){
            var data = obj.data;
            if (jquery.isEmptyObject(data)) {
                return false;
            }
            var url = tableURL + '?table=' + data.name;
            table.reload('lay-tableList', {
                url: url
            });
        });

    });
</script>
